package com.frejoys.admin.controller;

import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.black.BlackAddDto;
import com.frejoys.common.dto.black.BlackPageDto;
import com.frejoys.common.dto.common.IdDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.vo.black.BlackInfoVo;
import com.frejoys.common.vo.black.BlackPageVo;
import com.frejoys.service.BlackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "黑名单", description = "黑名单")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixAdmin)
@Authorization(Authority.Private)
public class AdminBlackController {

    private final BlackService blackService;


    /**
     * 添加
     *
     * @param dto
     * @return
     */
    @Operation(summary = "添加")
    @PostMapping("/black/add")
    public Result addInfo(@RequestBody @Validated BlackAddDto dto) {
        blackService.addInfo(dto);
        return Result.success();
    }

    /**
     * 后台分页查询黑名单
     */
    @Operation(summary = "分页查询黑名单")
    @PostMapping("/black/pageList")
    public Result<List<BlackPageVo>> pageList(@RequestBody @Validated BlackPageDto dto) {

        return Result.success(blackService.pageList(dto));

    }

    /**
     * 获取黑名单详情
     */
    @Operation(summary = "获取黑名单详情")
    @PostMapping("/black/getInfo")
    public Result<BlackInfoVo> getInfo(@RequestBody @Validated IdDto dto) {
        return Result.success(blackService.getInfo(dto));
    }

}
